package Demo0;

import java.io.*;

public class JpgCopy {
    public static void main(String[] args) {
        DataInputStream dis=null;
        DataOutputStream dos=null;

        try {
            dis=new DataInputStream(new FileInputStream("E:\\22\\11.jpg"));
            dos=new DataOutputStream(new FileOutputStream("E:\\11\\copy_原文件名.jpg"));
            int len=0;
            byte[] buf=new byte[1024];
            while((len = dis.read(buf)) > 0){
                dos.write(buf,0,len);
                dos.flush();
            }
            System.out.println("复制二进制文件成功");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(dos!=null){
                try {
                    dos.close();
                    dos=null;
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            if(dis!=null){
                try {
                    dis.close();
                    dis=null;
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }

    }
}
